package com.hk.servlet;

import com.alibaba.fastjson.JSONObject;
import com.hk.model.CompanyMessage;
import com.hk.model.Nav;
import com.hk.model.vo.ResultVO;
import com.hk.service.ICompanyMessageService;
import com.hk.service.INavService;
import com.hk.service.impl.CompanyMessageServiceImpl;
import com.hk.service.impl.NavServiceImpl;
import com.hk.utils.CharacterEncoding;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: zhe
 * @Date: 2021/6/22 17:56
 * @Statement: 导航栏信息
 */
@WebServlet("/nav/NavQuery")
public class NavQueryServlet extends HttpServlet {

    /**
     * 查询所有导航栏信息
     * @param req
     * @param resp
     * @throws ServletException
     * @throws IOException
     */
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        CharacterEncoding.setCharacterEncodingResp(req,resp,"UTF-8");
//        查询所有导航信息
        INavService iNavService = new NavServiceImpl();
        List<Nav> navList = iNavService.findAll(-1, -1);
        String navListJSON = JSONObject.toJSONString(navList);
        PrintWriter out = resp.getWriter();
        out.write(navListJSON);
        out.flush();
        out.close();
    }
}
